package com.wwlwxg.jvm;

import org.junit.Test;
import org.openjdk.jol.info.ClassLayout;

public class ObjectHead {
    @Test
    public void test1() throws InterruptedException {
        A a = new A();
        B b = new B();

        System.out.println(ClassLayout.parseInstance(a).toPrintable());
        System.out.println(ClassLayout.parseInstance(b).toPrintable());
        Thread.sleep(4000L);
        C c = new C();
        System.out.println(ClassLayout.parseInstance(c).toPrintable());
    }

    @Test
    public void test2() {
        A a = new A();
        System.out.println(ClassLayout.parseInstance(a).toPrintable());
        synchronized (a) {
            System.out.println(ClassLayout.parseInstance(a).toPrintable());
        }
        System.out.println(ClassLayout.parseInstance(a).toPrintable());
    }


    class B {
        public int a;
    }

    class C {
        public long b;
    }
}
